﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HZY.Admin.Controllers.Sys
{
    using HZY.EFCore;
    using HZY.EFCore.Entitys.Sys;
    using HZY.Services.Sys;
    using HZY.Toolkit;

    /// <summary>
    /// 用户管理
    /// </summary>
    public class UserController : ApiBaseController
    {
        private readonly UserService userService;

        public UserController(UserService _userService)
        {
            this.userService = _userService;
        }

        /// <summary>
        /// 查找数据
        /// </summary>
        /// <param name="Page"></param>
        /// <param name="Rows"></param>
        /// <param name="UserName"></param>
        /// <returns></returns>
        [HttpPost(nameof(FindList) + "/{Page}/{Rows}")]
        public async Task<TableViewModel> FindList(int Page, int Rows, string UserName)
        {

            //return await this.userService.FindListAsync(Page, Rows, Search);
            return null;
        }

        [HttpPost(nameof(Save))]
        public async Task<Sys_User> Save(Sys_User model)
        {
            return await this.userService.SaveAsync(model);
        }

        [HttpPost(nameof(Delete))]
        public async Task<ApiResult> Delete(List<Guid> Ids)
        {
            await this.userService.DeleteAsync(Ids);
            return this.ApiResult();
        }

        [HttpGet(nameof(FormById) + "/{Id}")]
        public async Task<Sys_User> FormById(Guid Id)
        {
            return await this.userService.FormByIdAsync(Id);
        }





    }
}